package com.lmh.util.demoutil;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

import com.google.gson.Gson;
import com.lmh.util.model.JsonRootBean;

public class JSonUTil {
	public static void main(String[] args) throws IOException {
		String json = "{\n" +
	            "  \"rst\": 0,\n" +
	            "  \"msg\": \"ok\",\n" +
	            "  \"data\": {\n" +
	            "    \"cookie\": \"JSESSIONID=abcntKeuJhop56LGykfdw\"\n" +
	            "  }\n" +
	            "}";
		String filePath = "C:\\Users\\TP\\Desktop\\testjson.json";
		InputStream is = new FileInputStream(new File(filePath));

		Reader reader = new InputStreamReader(is);
	    JsonRootBean jsonRootBean = new Gson().fromJson(reader, JsonRootBean.class);
	    System.out.println("rst:" + jsonRootBean.getRst());
	    System.out.println("msg:" + jsonRootBean.getMsg());
	    System.out.println("data:" + jsonRootBean.getData().getCookie());
	    is.close();
	    reader.close();
	}
	
}
